﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Configuration;

namespace AppHelper
{
    public class Common
    {
        public static string GetAppPath(HttpRequest request)
        {
            string path = string.Empty;
            try
            {
                if (request.ApplicationPath != "/")
                {
                    path = request.ApplicationPath;
                }
            }
            catch (Exception e)
            {
                path = "<b> Hata: </b><br/>" + e.Message;
            }
            return path;
        }

        public static string GetFilePath(HttpRequest request)
        {
            string path = string.Empty;
            try
            {
                if (request.FilePath != "/")
                {
                    path = request.FilePath;
                }
            }
            catch (Exception e)
            {
                path = "<b>Hata: </b><br />" + e.Message;
            }
            return path;
        }

        public static string GetConnectionString()
        {
            return ConfigurationManager.AppSettings["mysandbConnectionString"];
        }

        public static string GetCurrentCulture()
        {
            return System.Threading.Thread.CurrentThread.CurrentCulture.Name;
        }

        public static string ConvertToTurkish(string key)
        {
            key = key.Replace("ğ", "g");
            key = key.Replace("ö", "o");
            key = key.Replace("ş", "s");
            key = key.Replace("ı", "i");
            key = key.Replace("ü", "u");
            key = key.Replace("ç", "c");
            key = key.Replace("Ö", "O");
            key = key.Replace("Ş", "S");
            key = key.Replace("İ", "I");
            key = key.Replace("Ü", "U");
            key = key.Replace("Ç", "C");
            return key;
        }

    }
}
